home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / WorldScript.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  9.5 KB  |  358 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        WorldScript.h
  3.  
  4.      Contains:    WorldScript I Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1994-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __WORLDSCRIPT__
  19. #define __WORLDSCRIPT__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __TRAPS__
  25. #include <Traps.h>
  26. #endif
  27. #ifndef __QUICKDRAWTEXT__
  28. #include <QuickdrawText.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53. typedef UInt16                             WSIOffset;
  54. typedef UInt8                             WSIByteCount;
  55. typedef UInt8                             WSIByteIndex;
  56. /* offset from start of sub-table to row in state table */
  57. typedef UInt16                             WSIStateOffset;
  58. typedef UInt32                             WSITableOffset;
  59. typedef UInt16                             WSISubtableOffset;
  60. typedef UInt16                             WSIGlyphcode;
  61. typedef UInt32                             WSITableIdentifiers;
  62.  
  63. enum {
  64.     kScriptSettingsTag            = FOUR_CHAR_CODE('info'),
  65.     kMetamorphosisTag            = FOUR_CHAR_CODE('mort'),
  66.     kGlyphExpansionTag            = FOUR_CHAR_CODE('g2g#'),
  67.     kPropertiesTag                = FOUR_CHAR_CODE('prop'),
  68.     kJustificationTag            = FOUR_CHAR_CODE('kash'),
  69.     kCharToGlyphTag                = FOUR_CHAR_CODE('cmap'),
  70.     kGlyphToCharTag                = FOUR_CHAR_CODE('pamc'),
  71.     kFindScriptRunTag            = FOUR_CHAR_CODE('fstb')
  72. };
  73.  
  74.  
  75.  
  76. /****             L O O K U P    T A B L E    T Y P E S        ****/
  77.  
  78. enum {
  79.     WSILookupSimpleArray        = 0,                            /* a simple array indexed by glyph code */
  80.     WSILookupSegmentSingle        = 2,                            /* segment mapping to single value */
  81.     WSILookupSegmentArray        = 4,                            /* segment mapping to lookup array */
  82.     WSILookupSingleTable        = 6,                            /* sorted list of glyph, value pairs */
  83.     WSILookupTrimmedArray        = 8                                /* a simple trimmed array indexed by glyph code */
  84. };
  85.  
  86. typedef unsigned short                     WSILookupTableFormat;
  87. typedef unsigned short                     WSILookupValue;
  88. /* An offset from the beginning of the lookup table */
  89. typedef unsigned short                     WSILookupOffset;
  90. /*    FORMAT SPECIFIC DEFINITIONS */
  91. /*
  92.         lookupSimpleArray:
  93.         
  94.         This is a simple array which maps all glyphs in the font
  95.         to lookup values.
  96.     */
  97. struct WSILookupArrayHeader {
  98.     WSILookupValue                     lookupValues[1];            /* The array of values indexed by glyph code */
  99. };
  100. typedef struct WSILookupArrayHeader WSILookupArrayHeader;
  101.  
  102. /*
  103.         lookupTrimmedArray:
  104.         
  105.         This is a single trimmed array which maps a single range
  106.         of glyhs in the font to lookup values.
  107.     */
  108. struct WSILookupTrimmedArrayHeader {
  109.     WSIGlyphcode                     firstGlyph;
  110.     WSIGlyphcode                     limitGlyph;
  111.     WSILookupValue                     valueArray[1];
  112. };
  113. typedef struct WSILookupTrimmedArrayHeader WSILookupTrimmedArrayHeader;
  114.  
  115. /* The format specific part of the subtable header */
  116. union WSILookupFormatSpecificHeader {
  117.     WSILookupArrayHeader             simpleArray;                /* rename lookupArray as simpleArray <9> */
  118.     WSILookupTrimmedArrayHeader     trimmedArray;
  119. };
  120. typedef union WSILookupFormatSpecificHeader WSILookupFormatSpecificHeader;
  121.  
  122. /* The overall subtable header */
  123. struct WSILookupTableHeader {
  124.     WSILookupTableFormat             format;                        /* table format */
  125.     WSILookupFormatSpecificHeader     fsHeader;                    /* format specific header */
  126. };
  127. typedef struct WSILookupTableHeader WSILookupTableHeader;
  128.  
  129.  
  130. /****        G L Y P H    E X P A N S I O N    ****/
  131.  
  132. enum {
  133.                                                                 /* fixed 1.0 */
  134.     kCurrentGlyphExpansionVersion = 0x00010000
  135. };
  136.  
  137. typedef unsigned short                     GlyphExpansionFormats;
  138.  
  139. enum {
  140.     GlyphExpansionLookupFormat    = 1,
  141.     GlyphExpansionContextualFormat = 2
  142. };
  143.  
  144. struct ExpandedGlyphCluster {
  145.     WSIByteCount                     numGlyphs;
  146.     WSIByteIndex                     bestGlyph;
  147.     WSIGlyphcode                     glyphs[1];
  148. };
  149. typedef struct ExpandedGlyphCluster ExpandedGlyphCluster;
  150.  
  151. struct ExpandedGlyphOffset {
  152.     WSIGlyphcode                     glyph;
  153.     WSIOffset                         offset;                        /* offset to ExpandedGlyphCluster */
  154. };
  155. typedef struct ExpandedGlyphOffset ExpandedGlyphOffset;
  156.  
  157. struct GlyphExpansionStateTable {
  158.     WSISubtableOffset                 stateTableOffset;
  159.     WSISubtableOffset                 classTableOffset;
  160.     WSISubtableOffset                 actionTableOffset;            /* state, class and actions tables follow here... */
  161. };
  162. typedef struct GlyphExpansionStateTable GlyphExpansionStateTable;
  163.  
  164. struct GlyphExpansionTable {
  165.     Fixed                             version;
  166.     short                             format;
  167.     short                             expansionNumer;
  168.     short                             expansionDenom;                /* num/denom ratio for expansion <2> */
  169.  
  170.     union {
  171.         GlyphExpansionStateTable         stateTable;
  172.         WSILookupTableHeader             lookup;                    /* expanded glyph clusters follow here... */
  173.     }                                 table;
  174. };
  175. typedef struct GlyphExpansionTable GlyphExpansionTable;
  176.  
  177.  
  178. /* Glyph-to-Character constants and types  */
  179.  
  180. enum {
  181.     kCurrentGlyphToCharVersion    = 0x00010100
  182. };
  183.  
  184. typedef unsigned short                     GlyphToCharLookupFormats;
  185.  
  186. enum {
  187.     kGlyphToCharLookup8Format    = 1,
  188.     kGlyphToCharLookup16Format    = 2,
  189.     kGlyphToCharLookup32Format    = 3
  190. };
  191.  
  192. typedef UInt8                             GlyphToCharFontIndex;
  193. typedef UInt8                             QDGlyphcode;
  194. struct GlyphToCharActionTable {
  195.     WSISubtableOffset                 fontNameOffset;                /* offset relative to this table */
  196.     WSILookupTableHeader             actions;                    /* only support lookupSimpleArray format for now */
  197. };
  198. typedef struct GlyphToCharActionTable GlyphToCharActionTable;
  199.  
  200. struct GlyphToCharActionHeader {
  201.     short                             numTables;                    /* 0..n */
  202.     WSISubtableOffset                 offsets[1];                    /* offsets from start of action table header */
  203. };
  204. typedef struct GlyphToCharActionHeader GlyphToCharActionHeader;
  205.  
  206. struct GlyphToCharHeader {
  207.     Fixed                             version;
  208.  
  209.     WSISubtableOffset                 actionOffset;                /* offset to GlyphToCharActionHeader */
  210.  
  211.     short                             format;                        /* size of font mask */
  212.     WSILookupTableHeader             mappingTable;
  213. };
  214. typedef struct GlyphToCharHeader GlyphToCharHeader;
  215.  
  216.  
  217. /* JUSTIFICATION TYPES
  218.     WorldScript supports justification of text using insertion. The justification
  219.     table specifies a insertion string to insert between 2 specified glyphs.
  220.     Each combination of inter-glyph boundary can be assigned a justification priority,
  221.     the higher the priority the more justification strings inserted at that position.
  222.     
  223.     The priorities for each inter-glyph boundary are specified by the justification table's
  224.     state table.
  225.     
  226.     Special handling is done for scripts which use spaces to justify, because the width of 
  227.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  228.     per inserting string is specified in the justification table.
  229.  
  230. */
  231.  
  232. enum {
  233.                                                                 /* 1.0 not supported */
  234.     kCurrentJustificationVersion = 0x0200
  235. };
  236.  
  237.  
  238. enum {
  239.     kJustificationStateTableFormat = 1
  240. };
  241.  
  242.  
  243. enum {
  244.                                                                 /* WSI's internal limitation <12> */
  245.     kMaxJustificationStringLength = 13
  246. };
  247.  
  248. typedef UInt8                             WSIJustificationPriority;
  249.  
  250. enum {
  251.     WSIJustificationSetMarkMask    = 0x80
  252. };
  253.  
  254. struct WSIJustificationStateEntry {
  255.     WSIJustificationPriority         markPriority;                /* non-zero priorities means insertion */
  256.     WSIJustificationPriority         priority;
  257.     WSIStateOffset                     newState;
  258. };
  259. typedef struct WSIJustificationStateEntry WSIJustificationStateEntry;
  260.  
  261. typedef unsigned short                     WSIJustificationClasses;
  262.  
  263. enum {
  264.     wsiJustEndOfLineClass        = 0,
  265.     wsiJustEndOfRunClass        = 1,
  266.     wsiJustDeletedGlyphClass    = 2,
  267.     wsiJustUserDefinedClass        = 3
  268. };
  269.  
  270. typedef unsigned short                     WSIJustificationStates;
  271.  
  272. enum {
  273.     wsiStartOfLineState            = 0,                            /* pre-defined states */
  274.     wsiStartOfRunState            = 1,
  275.     wsiUserDefinedState            = 2
  276. };
  277.  
  278. /* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) */
  279. typedef UInt8                             WSIJustificationClassOffset;
  280. struct WSIJustificationStateTable {
  281.     short                             maxPriorities;
  282.     unsigned short                     rowWidth;                    /* width of a state table row in bytes */
  283.     short                             classTableOffset;
  284.     short                             stateTableOffset;
  285. };
  286. typedef struct WSIJustificationStateTable WSIJustificationStateTable;
  287.  
  288. /*
  289.             Last two fields of above structure - someday?
  290.             WSIJustificationClassOffset    classes[up to 64 classes supported];
  291.             WSIJustificationStateEntry    states[up to your heart's desire];
  292.         */
  293. struct WSIJustificationHeader {
  294.     short                             version;
  295.     short                             format;
  296.  
  297.     Point                             scaling;                    /* numer/denom scaling of priority weights <7> */
  298.  
  299.     unsigned short                     spacesPerInsertion;            /* # of $20 chars in justification insertion string <12> */
  300.     unsigned short                     justStringOffset;            /* offset to justification string */
  301.  
  302.  
  303.     WSIJustificationStateTable         stateTable;                    /* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows */
  304. };
  305. typedef struct WSIJustificationHeader WSIJustificationHeader;
  306.  
  307.  
  308. /* Line Layout's Property table version <11> */
  309.  
  310. enum {
  311.                                                                 /* v1.0 */
  312.     currentPropsTableVersion    = 0x00010000
  313. };
  314.  
  315.  
  316. enum {
  317.                                                                 /* version is octal 0100 or hex 0x40 (#64) */
  318.     kCharToGlyphCurrentVersion    = 0x40
  319. };
  320.  
  321. /* pass as priorityWeight to JustifyWSILayout to use script's current just setting */
  322.  
  323. enum {
  324.     kScriptsDefaultJustWeight    = -1
  325. };
  326.  
  327.  
  328. /* feature selectors used in FindScriptRun and itl5 configuration tables <9> */
  329. typedef UInt16                             WSIFeatureType;
  330. typedef UInt16                             WSIFeatureSelector;
  331. struct WSIFeature {
  332.     WSIFeatureType                     featureType;
  333.     WSIFeatureSelector                 featureSelector;
  334. };
  335. typedef struct WSIFeature WSIFeature;
  336.  
  337.  
  338. #if PRAGMA_STRUCT_ALIGN
  339.     #pragma options align=reset
  340. #elif PRAGMA_STRUCT_PACKPUSH
  341.     #pragma pack(pop)
  342. #elif PRAGMA_STRUCT_PACK
  343.     #pragma pack()
  344. #endif
  345.  
  346. #ifdef PRAGMA_IMPORT_OFF
  347. #pragma import off
  348. #elif PRAGMA_IMPORT
  349. #pragma import reset
  350. #endif
  351.  
  352. #ifdef __cplusplus
  353. }
  354. #endif
  355.  
  356. #endif /* __WORLDSCRIPT__ */
  357.  
  358.